//
// Created by hugan on 2020/11/22.
//

#ifndef HUP_UTILS_PARENT_CPP_CHARSETCONVERTER_H
#define HUP_UTILS_PARENT_CPP_CHARSETCONVERTER_H
#pragma once

#include <jni.h>
#include <iostream>
#include <string>
#include <windows.h>

/**
 * C++实现编码转换
 * https://www.cnblogs.com/gongluck/p/12557075.html
 */
class CharsetConverter {
public:
    static int multi2uni(const std::string &multi, std::wstring &uni, UINT code);

    static int uni2multi(const std::wstring &uni, std::string &multi, UINT code);

    static int ansi2uni(const std::string &ansi, std::wstring &uni);

    static int uni2ansi(const std::wstring &uni, std::string &ansi);

    static int utf82uni(const std::string &utf8, std::wstring &uni);

    static int uni2utf8(const std::wstring &uni, std::string &utf8);

    static int ansi2utf8(const std::string &ansi, std::string &utf8);

    static int utf82ansi(const std::string &utf8, std::string &ansi);

    static void jString2ansi(JNIEnv *env, jstring &str, std::string &ansi);
};

#endif //HUP_UTILS_PARENT_CPP_CHARSETCONVERTER_H
